#include <iostream>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

class Solution1 {
public:
    using pii = pair<int, int>;

    long long totalCost(vector<int>& costs, int k, int candidates) {
        int n = costs.size();

        priority_queue<pii, vector<pii>, greater<pii>> pq;
        int l = candidates - 1, r = n - candidates;
        if (l + 1 >= r)
        {
            for (int i = 0; i < n; ++i)
                pq.push({ costs[i], i });
        }
        else
        {
            for (int i = 0; i <= l; ++i)
                pq.push({ costs[i], i });
            for (int i = r; i < n; ++i)
                pq.push({ costs[i], i });
        }

        long long res = 0;
        while (k--)
        {
            auto [cost, i] = pq.top(); pq.pop();
            res += cost;
            if (l + 1 < r)
            {
                if (i <= l)
                {
                    l++;
                    pq.push({ costs[l], l });
                }
                else
                {
                    r--;
                    pq.push({ costs[r], r });
                }
            }
        }

        return res;
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n + 1);
    int cnt = 0; int mxcnt = 0;
    for (int i = 0; i < n; ++i)
    {
        int cur; cin >> cur;
        if (h[cur]++ == 0) cnt++;
        mxcnt = max(mxcnt, h[cur]);
    }

    if (n < m || cnt > m)
    {
        cout << -1 << endl;
        return 0;
    }

    function<int(int)> check = [&](int x)
    {
        int sum = 0;
        for (int i = 1; i <= n; ++i)
            sum += h[i] / x + (h[i] % x == 0 ? 0 : 1);
        return sum;
    };

    int l = 1, r = mxcnt;
    while (l < r)
    {
        int mid = (l + r) >> 1;
        if (check(mid) > m)
            l = mid + 1;
        else
            r = mid;
    }
    cout << r << endl;

    return 0;
}